import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { CommonEnum } from '@/enums';

import './index.less';

export default function ShowLoading(props) {
  const [flag, setFlag] = useState(false)

  useEffect(() => {
    setTimeout(()=>{
      setFlag(true)
    })
  }, [])

  return (
    <div>
      {props.showLoading && flag ? <div id={CommonEnum.LOADING_ID} className='loading-info'>loading</div> : <div className='loading-info'>没有数据了~</div>}
    </div>
  )
}

ShowLoading.defaultProps = {
  showLoading: true,
};

ShowLoading.propTypes = {
  showLoading: PropTypes.bool
};
